
import { Component } from "react";
import propTypes from 'prop-types'
class Login extends Component {
    //初始化属性和方法
    constructor(props) {
        console.log(props);

        super(props);
        this.state={
            title:"hello wrold",
            userInfo:{username:"ldq",pass:""},
            msg:"login"


        }
        this.login=this.login.bind(this);
    }
    static propTypes={
        id:propTypes.number.isRequired
    }
    static defaultProps={

         title:"默认值"
         
    }
    update=()=>{
        
        this.setState({title:"你好，世界"},()=>{
            console.log(22222,this.state.title);
        })
     
        console.log(111111,this.state.title);

        // this.setState((prestate)=>{
        //     console.log(prestate.msg);

        //     return {
        //         msg:"登录"
        //     }

        // })


    }
    reg=(val,e)=>{

       console.log(val);
       console.log(e);
    }
    reg2=(val)=>{
        return(e)=>{
            console.log(222,val);
            console.log(111,e);
             
        }
     }
     reg3=()=>{
       console.log(111111111111);
     }
    login(val,e){
        console.log(e);
        console.log(val);

        
    }
    submit(e,val){
        console.log(e);
        console.log(val);
    
    }
    
    render() {

        return <div>
            {this.props.title}
            {this.props.id}
            <h1>{this.state.msg}</h1>
            <h1>{this.state.title}</h1>

            <button onClick={this.update}>修改state</button>
       
             
                <button onClick={(e)=>this.submit(e,100)}>提交</button>
                <button onClick={this.login.bind(this,200)}>提交</button>
                <button onClick={this.reg.bind(this,300)}>提交</button>

                <button onClick={this.reg2(300)}>提交</button>

                <button onClick={this.reg3}>提交</button>
           
        </div>
    }


}
export default Login;